#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();return x*f;}
inline void write(int x){if(x<0)putchar('-'),x=-x;if(x>=10)write(x/10);putchar(x%10+'0');}
struct Node{
    int l,r;
    bool operator < (Node a){
        if(l!=a.l){
            return l<a.l;
        }else{
            return r<a.r;
        }
    }
};
int d[100005],v[100005],a[100005],p[100005],s[100005],w[100005];
void main1(){
    vector<Node>ve,v1;
    int n=read(),m=read(),len=read(),xs=read(),xs2=xs*xs,ans=0;
    for(int i=0;i<n;++i){
        d[i]=read(),v[i]=read(),a[i]=read();
    }
    for(int i=1;i<=m;++i){
        p[i]=read();
    }
    for(int i=0;i<n;++i){
        if(v[i]>xs && a[i]>=0){
            int le=lower_bound(p+1,p+m+1,d[i])-p;
            if(le<=m){
                ve.push_back({le,m});
                ++ans;
            }
        }else if(v[i]<=xs && a[i]>0){
            int cs=floor((xs2-v[i]*v[i])*1.0/a[i]/2);
            int le=upper_bound(p+1,p+m+1,d[i]+cs)-p;
            if(le<=m){
                ve.push_back({le,m});
                ++ans;
            }
        }else if(v[i]>xs && a[i]<0){
            int cs=ceil((xs2-v[i]*v[i])*1.0/a[i]/2);
            int le=lower_bound(p+1,p+m+1,d[i])-p;
            int ri=lower_bound(p+1,p+m+1,d[i]+cs)-p-1;
            if(ri>m){
                ri=m;
            }
            if(le<=ri){
                ve.push_back({le,ri});
                ++ans;
            }
        }
    }
    write(ans);
    putchar(' ');
    memset(s,0,sizeof(s));
    for(int i=0;i<ve.size();++i){
        if(ve[i].l==ve[i].r){
            s[ve[i].l]=1;
        }
    }
    for(int i=1;i<=m;++i){
        s[i]+=s[i-1];
    }
    for(int i=0;i<ve.size();++i){
        if(s[ve[i].r]==s[ve[i].l-1]){
            v1.push_back(ve[i]);
        }
    }
    ans=s[m]+1;
    sort(v1.begin(),v1.end());
    if(!v1.empty()){
        w[v1.size()-1]=v1[v1.size()-1].l;
    }else{
        --ans;
    }
    for(int i=v1.size()-2;i>=0;--i){
        if(v1[i].r<v1[i+1].l){
            ++ans;
            w[i]=v1[i].l;
        }else{
            if(v1[i].r>=w[i+1]){
                w[i]=w[i+1];
            }else{
                ++ans;
                w[i]=v1[i].l;
            }
        }
    }
    write(m-ans);
    return;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t=read();
    while(t--){
        main1();
        putchar('\n');
    }
    return 0;
}
